<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('分配角色选择用户')" />
</head>

<body class="gray-bg">
					<input id="custId"   name="custId"    type="hidden" />
					<input id="custName" name="custName"  type="hidden" />
					<input id="certNo" name="certNo"  type="hidden" />
					<input id="custType" name="custType"  type="hidden" />
	<div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="role-form">
					<div class="select-list">
						<ul>
                            <li>
                                <label>客户名称：</label>
                                <input type="text" name="custName"/>
                            </li>
                            <li>
                                <label>证件号码：</label>
                                <input type="text" name="certNo"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
						</ul>
					</div>
				</form>
			</div>
	        
	        <div class="col-sm-12 select-table table-striped">
			    <table id="bootstrap-table"></table>
			</div>
		</div>
	</div>
	<th:block th:include="include :: footer" />
	<script th:inline="javascript">
	    var prefix = ctx + "crm/custinfo";
	
	    $(function() {
	        var options = {
	            url: prefix + "/query",
	            modalName: "客户信息",
		        showSearch: false,
		        showRefresh: false,
		        showToggle: false,
		        showColumns: false,
		        clickToSelect: true,
		        rememberSelected: true,
	            columns: [{
	                /* checkbox: true */
	                radio: true
	            },
	            {
	                field: 'custId',
	                title: 'id',
	                visible: true
	            },
	            {
	                field: 'custName',
	                title: '名称'
	            },
	            {
	                field: 'custType',
	                title: '客户类型',
	                align: 'center',
	                formatter: function(value, row, index) {
	                    if (row.custType==0) {
	                    	return "个人";
	                    } else {
	                    	return "单位";
	                    }
	                }
	            },
	            {
	                field: 'certNo',
	                title: '社会信用号码/身份号码'
	            },
		        {
		            field: 'createTime',
		            title: '创建时间',
		            sortable: true
		        }
	            ]
	        };
	        $.table.init(options);
	    });
				
		/* 添加用户-选择用户-提交 */
		function submitHandler() {
			var rows = $.table.selectFirstColumns();
			if (rows.length == 0) {
       			$.modal.alertWarning("请至少选择一条记录");
       			return;
       		} else if (rows.length>1) {
       			$.modal.alertWarning("请选择一条记录");
       			return;
       		} else {
       			var rowsData = $('#bootstrap-table').bootstrapTable('getSelections');
       			var row = rowsData[0];
       			$("#custId").val(row.custId);
       			$("#custName").val(row.custName);
       			$("#certNo").val(row.certNo);
       			$("#custType").val(row.custType);
       		}
		}
	</script>
</body>
</html>